package com.example.bysj_sb.service;

import com.example.bysj_sb.dao.StudentClassDao;
import com.example.bysj_sb.domain.School;
import com.example.bysj_sb.domain.StudentClass;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service("studentClassService")
//@Transactional注解：可以用在方法上和类上，用在类上代表这个类的所有公共非静态方法都将启用事务功能。
@Transactional(isolation = Isolation.READ_COMMITTED, propagation = Propagation. REQUIRED)
public class StudentClassService {
    @Autowired
    private StudentClassDao studentClassDao;

    //添加
    public Boolean add(StudentClass studentClass){
        return studentClassDao.add(studentClass);
    }
    //根据id查找
    public StudentClass find(int id){
        StudentClass studentClass = studentClassDao.find(id);
        return studentClass;
    }
    //查找全部
    public List<StudentClass> findAll(){
        List<StudentClass> studentClasses = studentClassDao.findAll();
        return studentClasses;
    }
    //修改
    public Boolean update(StudentClass studentClass){
        return studentClassDao.update(studentClass);
    }
    //删除
    public Boolean delete(int id){
        return studentClassDao.delete(id);
    }
}
